<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('订单管理')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
    <link rel="stylesheet" th:href="@{/static/js/editable/css/bootstrap-editable.css}">
    <!-- <style type="text/css">.table {table-layout:fixed;}</style> -->
</head>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-condition">
            <form id="orderItemForm" th:action="@{/orderItem/list?poFlag=SNPRO}" class="form-inline">
                <div class="select-list">
                    <ul>
                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">采购凭证号：</label>
                            <input type="text" name="poNo" />
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">订单类型：</label>
                            <select name="poType" sysDict="CGDDLX" emptyFirst="true"></select>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">供应商编码：</label>
                            <input type="text" name="sapCode"/>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">采购组：</label>
                            <select name="purchGroup" sysDict="CGZ" emptyFirst="true"></select>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">物料编码：</label>
                            <input type="text" name="materialCode" />
                        </li>

                        <li class="col-sm-3" style="width: 33%">
                            <label style="width: 120px">物料描述：</label>
                            <input type="text" name="materialDesc" />
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <button id="orderItemSearchBtn" type="button" class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置</button>
                            <button id="orderItemAdvancedSearch" type="button" class="btn btn-primary btn-rounded btn-sm" style="display: none"><i class="fa fa-caret-down"></i>&nbsp;高级搜索</button>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-info order-table">
            <div class="btn-group hidden-xs toolbar" id="orderItemToolBar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="toEdit()" shiro:hasPermission="orderItem:changer">
                    <i class="fa fa-edit"></i> 变更
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toUpdate() " shiro:hasPermission="orderItem:confirm">
                    <i class="fa fa-star"></i> 确认
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toRemove()" shiro:hasPermission="orderItem:cancel">
                    <i class="fa fa-star"></i> 取消
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toSendSap()" shiro:hasPermission="orderItem:sendSap">
                    <i class="fa fa-star"></i> 同步SAP
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toSend()" shiro:hasPermission="orderItem:fahuo">
                    <i class="fa fa-star"></i> 发货
                </a>
                <a class="btn btn-outline btn-success btn-rounded" id="sendid" data-toggle='modal' data-target='' shiro:hasPermission="orderItem:fpfahuo" onclick="toSendBatche()">
                    <i class="fa fa-plus"></i> 分批发货
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="showUploadDialog()">
                    <i class="fa fa-upload"></i> 上传报告
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="showdownloadDialog()">
                    <i class="fa fa-download"></i> 下载报告
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="showReportDetailDialog()">
                    <i class="fa fa-search"></i> 查看报告
                </a>
            </div>
            <table id="orderItem" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<!--上传报告-->
<div id="uploadModal" style="display: none">
    <div class="modal-body">
        <form id="uploadForm" enctype="multipart/form-data">
            <div style="margin-top:20px">
                <label><b>上传类型：</b></label>
                <label id="uploadType" >
                </label>
                <label style="color: red">*</label>
            </div>
            <div style="margin-top:20px"><label><b>选择文件：</b></label><input type="file" name="reportFile" id="reportFile" style="display:inline"> <label style="color: red">*</label></div>
            <div style="margin-top:20px"><label><b>备注：</b></label><textarea id="remark" name="remark" style="width:80%; height:150px;"></textarea></div>
        </form>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" onclick='closeDialog()'>关闭</button>
        <button type="button" class="btn btn-primary" onclick='uploadReport()'>确定</button>
    </div>
</div>

<!--下载报告-->
<div id="downloadModal" style="display: none">
    <div class="modal-body">
        <form id="downloadForm" method="post">
            <div class="checkbox" id="downloadCheckbox">
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" onclick='closeDialog()'>关闭</button>
        <button type="button" class="btn btn-primary" onclick='downloadReport()'>确定</button>
    </div>
</div>

<!--查看报告-->
<div id="reportDetailModal" style="display: none">
    <div class="modal-body">
        <table class="table" id="reportDetailTable">
            <thead>
            <tr>
                <th data-field="type">报告类型</th>
                <th data-field="isUpload">是否上传</th>
                <th data-field="time">上传时间</th>
                <th data-field="remark">备注</th>
            </tr>
            </thead>
        </table>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" onclick='closeDialog()'>关闭</button>
    </div>
</div>

<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<!-- Page-Level Scripts -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document" style="width:70%">
        <div class="modal-content" style="height:700px">
            <form id="orderForm" th:action="@{/orderItem/list}" class="form-inline">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">发货信息明细</h4>
                </div>
                <input type="hidden" id="ids" name="ids" value="" />
                <div class="modal-body" style="height:90%;width:90%;overflow:auto">
                    <div style="height: 30px">
                        <ul>
                            <li class="col-sm-3" style="width: 33.3%">
                                <label style="width: 90px">采购凭证号：</label>
                                <input type="text" id="poNo" name="poNo" />
                            </li>
                            <li class="col-sm-3" style="width: 33.3%">
                                <label style="width: 70px">订单类型：</label>
                                <select id="poType" name="poType" sysDict="CGDDLX" emptyFirst="true"></select>
                            </li>
                            <li class="col-sm-3" style="width: 33.3%">
                                <label style="width: 120px">供应商编码：</label>
                                <input type="text" id="sapCode" name="sapCode"/>
                            </li>
                            <li class="col-sm-3" style="width: 33.3%">
                                <label style="width: 70px">采购组：</label>
                                <select id="purchGroup" name="purchGroup" sysDict="CGZ" emptyFirst="true" style="width: 55%"></select>
                            </li>
                            <li class="col-sm-3" style="width: 33.3%">
                                <label style="width: 120px">物料编码：</label>
                                <input type="text" id="materialCode" name="materialCode" />
                            </li>
                            <li class="col-sm-3" style="width: 33.3%">
                                <button id="orderSearchBtn" type="button" class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置</button>
                                <button id="orderAdvancedSearch" type="button" class="btn btn-primary btn-rounded btn-sm" style="display: none"><i class="fa fa-caret-down"></i>&nbsp;高级搜索</button>
                            </li>
                        </ul>
                    </div>
                    <table id="order" data-mobile-responsive="true"></table>
                </div>
            </form>
            <div class="modal-footer">
                <button id="close" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick='save()'>确定</button>
            </div>
        </div>
    </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

<script type="text/javascript">
    //面向对象
    var searcherBS = Searcher.createBS('#orderItem',
        [
            {checkbox: true},
            {title: '采购凭证号', field:'poNo'},
            {title: '订单确认状态', field:'itemStatus',
                formatter : function (value, row, index) {
                    if(value ==0) {
                        return "草稿";
                    } else if(value == -1) {
                        return "订单已经取消";
                    }else if(value == 1) {
                        return "订单已确认";
                    }else if(value == 2) {
                        return "分批发货";
                    }else if(value == 3) {
                        return "订单发货完毕";
                    }else if(value==4){
                        return "SAP同步成功";
                    }
                }
            },
            {title: '行项目号', field:'itemNo'},
            {title: '物料编码', field:'materialCode'},
            {title: '物料描述', field:'materialDesc'},
            {title: '工厂', field:'factory'},
            {title: '库存地点', field:'storageLocation'},
            {title: '物料组', field:'materialGroup'},
            {title: '需求者姓名', field:'requester'},
            {title: '采购订单数量', field:'poCount'},
            {title: '待发货的数量',field:'backOrders'},
            {title: '采购订单的计量单位', field:'poUnit'},
            {title: '含税单价', field:'poPrice'},
            {title: '价格单位', field:'priceUnit'},
            {title: '税码', field:'taxCode'},
            {title: '订单总价值', field:'totalPrice'},
            {title: '发票收据标识', field:'receiveFlag'},
            {title: '采购申请编号', field:'prNo'},
            {title: '采购申请项目编号', field:'prItemNo'},
            {title: '交货日期', field:'deliveryDate'},
            {title: '成本中心', field:'costCenter'},
            {title: '备注', field:'remark'},
            {title: '订单类型', field:'poType'},
            {title: '供应商', field:'vendorId'},
            {title: '公司代码', field:'companyCode'},
            {title: '采购组', field:'purchGroup'},
            {title: '采购组织', field:'purchOrg'},
            {title: '采购订单更改日期', field:'sapUtime'},
            {title: '付款条件代码', field:'payCondition'},
            {title: '国际贸易条款', field:'i18nTradeTerms'},
            {title: '货币码', field:'currencyCode'},
            {title: '公司名称', field:'companyName'},
            {title: '国家', field:'country'},
            {title: '城市', field:'city'},
            {title: '电话', field:'telNo'},
            {title: '供应商名称', field:'vendorName'},
            {title: '创建日期', field:'creationDate'},
            {title: "第一次出货报告",field:'deliverFirstRemark',
                formatter: function(value,row,index){
                    var val='';
                    if(value){
                        val=value;
                    }
                    if(row.deliverFirstFile){
                        return "<img src='" + ctxPath + "/img/duicuo/dui.png' width='20px' />"+val;
                    }
                    return "<img src='" + ctxPath + "/img/duicuo/cuo.png' width='20px' />"+val;
                }
            },
            {title: "第二次出货报告",field:'deliverSecondRemark',
                formatter: function(value,row,index){
                    var val='';
                    if(value){
                        val=value;
                    }
                    if(row.deliverSecondFile){
                        return "<img src='" + ctxPath + "/img/duicuo/dui.png' width='20px' />"+val;
                    }
                    return "<img src='" + ctxPath + "/img/duicuo/cuo.png' width='20px' />"+val;
                }
            },
            {title: "第三次出货报告",field:'deliverThirdRemark',
                formatter: function(value,row,index){
                    var val='';
                    if(value){
                        val=value;
                    }
                    if(row.deliverThirdFile){
                        return "<img src='" + ctxPath + "/img/duicuo/dui.png' width='20px' />"+val;
                    }
                    return "<img src='" + ctxPath + "/img/duicuo/cuo.png' width='20px' />"+val;
                }
            }
        ]
    );

    /**
     * 查询数据
     */
    function refresh() {
        searcherBS.refresh();
    }
    /*
    *初始化所有字典数据
    */
    $(function () {
        initDictDataSel();
    });

    /**
     * 编辑
     */
    function toEdit() {
        var rowDatas = searcherBS.getSelectedRows("poNo");
        //草稿状态订单可以变更
        var rowData = $("#orderItem").bootstrapTable('getSelections');
        var goodsStatus;

        if (rowDatas.length != 1) {
            Dialog.errorMsg("请选择一行进行编辑");
            return;
        }
        for(var i=0;i<rowData.length;i++){
            goodsStatus = rowData[i].itemStatus;
        }
        if(goodsStatus==-1){
            var index = Dialog.openUrl("更改订单信息", ctxPath + '/orderHead/toEdit/'+rowDatas,
                {area : ['900px','700px'],
                    maxmin: true,
                    end: function () {}
                });
            layer.full(index);
        }else{
            Dialog.errorMsg("订单不是草稿状态");
            return;
        }
    }

    /**
     * 确认订单
     */
    function toUpdate() {
        var rowDatas = searcherBS.getSelectedRows("poItemId");
        Page.ajaxPOST(ctxPath + "/orderItem/toupdate", {"ids" : rowDatas}, function (data) {
            Dialog.msg(data.result);
            searcherBS.refresh();
        });
    }
    /**
     * 取消订单
     */
    function toRemove() {
        var rowDatas = searcherBS.getSelectedRows("poItemId");
        Page.ajaxPOST(ctxPath + "/orderItem/toRemove", {"ids" : rowDatas}, function () {
            Dialog.msg("操作成功", function () {
                Dialog.msg(data.result);
                searcherBS.refresh();
            });
        });
        //searcherBS.refresh();
    }

    /**
     发货
     */
    function toSend() {
        var rowDatas = searcherBS.getSelectedRows("poItemId");
        var rowData = $("#orderItem").bootstrapTable('getSelections');
        var goodsStatus;
        if (rowData.length < 1) {
            Dialog.errorMsg("请至少选择一行进行编辑");
            return;
        }
        for(var i=0;i<rowData.length;i++){
            goodsStatus = rowData[i].itemStatus;
        }
        if(goodsStatus==4){
            Page.ajaxPOST(ctxPath + "/orderItem/toSend", {"ids" : rowDatas}, function () {
                Dialog.msg("操作成功", function () {
                    searcherBS.refresh();
                });
            }, {"loadingMsg" : "正在往服务器提交数据……"});
        }else{
            Dialog.errorMsg("订单没有同步SAP!");
            document.getElementById("close").click();
            return;
        }
    }

    /**
     分批发货
     */
    //方法一
    /* document.getElementById("importJsp").setAttribute("src","#");
     //iframe标签的src属性值已更改为"#"
     console.log(document.getElementById("importJsp").getAttribute("src"));
     //方法二
     document.getElementById("importJsp").attributes["src"].value="#";
     //iframe标签的src属性值已更改为"#"
     console.log(document.getElementById("importJsp").getAttribute("src"));*/
    var searcherbs;
    function toSendBatche(){
        $("#order").find("tbody").remove();
        //得到选中的行项目id
        var rowDatas = searcherBS.getSelectedRows("poItemId");
        var rowData = $("#orderItem").bootstrapTable('getSelections');
        var goodsStatus;
        if (rowDatas.length < 1) {
            Dialog.errorMsg("请至少选择一行进行编辑");
            return;
        }
        for(var i=0;i<rowData.length;i++){
            goodsStatus = rowData[i].itemStatus;
            if(goodsStatus==1||goodsStatus==2){
                document.getElementById("sendid").setAttribute("data-target","#myModal");
                $("#ids").val(rowDatas);
                searcherbs = Searcher.createBS('#order',
                    [
                        //{checkbox: true },
                        {title: '物料编码', field:'materialCode',clickToSelect: false },
                        {title: '物料描述', field:'materialDesc',clickToSelect: false},
                        {title: '采购凭证号', field:'poNo',clickToSelect: false },
                        {title: '订单确认状态', field:'itemStatus',clickToSelect: false },
                        {title: '行项目号', field:'itemNo',clickToSelect: false },
                        {title: '采购订单数量', field:'poCount',clickToSelect: false },
                        {title: '已发货数量', field:'shippedQty' ,clickToSelect: false  },
                        //editable:true,//开启编辑模式
                        {title: '本次发货数量', field:'dueOut',
                            formatter: function(value,row,index,field){
                                return '<input oninput="OnInput (event)" onchange="change('+this+')" contenteditable="true" type="number" name="dueOut" size="10" id="ipt' + row.poItemId +'" min="0" max="'+(row.poCount-row.shippedQty)+'" value="'+(row.poCount-row.shippedQty)+'">';
                            },
                            clickToSelect: false //是否启用点击选中行
                        }
                    ],{pageList: [10], pageSize : 10, showColumns: false ,
                        onCheck : function(row) {},
                        onPostBody : function() {}
                    }
                );
                searcherbs.refresh();

            }else{
                document.getElementById("sendid").setAttribute("data-target","");
                Dialog.errorMsg("订单没有确认");
                return;
            }
        }
    }
    /**
     * 保存
     */
    function save() {
        var myMap = {};
        //得到选中的行
        var ss = searcherbs.getSelectedRows("poItemId");
        var ss=$("#ids").val().split(",");
        for ( var i = 0; i <ss.length; i++){
            myMap[ss[i]] = $("#ipt"+ss[i]).val();
        }
        var json={"ids":myMap};
        Page.ajaxPOST(ctxPath + "/orderItem/save",JSON.stringify(json), function () {
            Dialog.msg("操作成功", function () {
                searcherBS.refresh();
            });
        }, {contentType : "application/json",},{"loadingMsg" : "正在往服务器提交数据……"});
        $('#myModal').modal('hide');
    }
    /**
     * 传输SAP
     */
    function toSendSap(){
        var rowData = $("#orderItem").bootstrapTable('getSelections');
        var goodsStatus;
        if (rowData.length < 1) {
            Dialog.errorMsg("请至少选择一行进行编辑");
            return;
        }
        for(var i=0;i<rowData.length;i++){
            goodsStatus = rowData[i].itemStatus;
        }
        if(goodsStatus==1){
            var rowDatas = searcherBS.getSelectedRows("poItemId");
            Page.ajaxPOST(ctxPath + "/orderItem/toSendSap", {"ids" : rowDatas}, function () {
                Dialog.msg("同步成功!", function () {
                    searcherBS.refresh();
                });
            }, {"loadingMsg" : "正在往服务器提交数据……"});
        }else if(goodsStatus==4){
            Dialog.errorMsg("该订单已经同步SAP!");
        }else{
            Dialog.errorMsg("订单没有确认!");
        }
    }


    /**
     *上传报告
     */
    function showUploadDialog() {
        var rowData = searcherBS.getRawData();
        if (rowData.length != 1) {
            Dialog.errorMsg("请选择一行进行上传！");
            return;
        }
        rowData=rowData[0];
        //报告均已上传
        if(rowData.deliverFirstFile&&rowData.deliverSecondFile&&rowData.deliverThirdFile){
            Dialog.errorMsg("所有报告均已上传！");
            return;
        }
        //上传报告窗口
        Dialog.open('文件上传', $("#uploadModal"),{area : ['500px','450px']});
        //动态添加选项
        var node='';
        var nodeValue='';
        if(!rowData.deliverFirstFile){
            node+="第一次出货检验报告";
            nodeValue='deliverFirstFile';
        }else if(!rowData.deliverSecondFile){
            node+="第二次出货检验报告";
            nodeValue='deliverSecondFile';
        }else if(!rowData.deliverThirdFile){
            node+="第三次出货检验报告";
            nodeValue='deliverThirdFile';
        }
        $("#uploadType").text(node);
        $("#uploadType").val(nodeValue);
    }

    //上传文件取消
    function closeDialog(){
        layer.closeAll();
    }

    function uploadReport(){
        var uploadType=$("#uploadType").val();
        var reportFile=$("#reportFile").val();
        if(!reportFile){
            Dialog.errorMsg("请上传文件！");
            return;
        }
        var rowData = searcherBS.getRawData()[0];
        var formData=new FormData($('#uploadForm')[0]);
        formData.append("poItemId",rowData.poItemId);
        formData.append("uploadType",uploadType);
        uploadId=rowData.uploadId;
        if(uploadId==undefined||uploadId==null){
            uploadId='';
        }
        formData.append("uploadId",uploadId);
        layer.load(1,{shade: [0.3, '#393D49']});
        $.ajax({
            url: ctxPath + "/orderItem/uploadFile",
            type: 'POST',
            data: formData, // 上传formdata封装的数据包
            dataType: 'JSON',
            cache: false, // 不缓存
            processData: false, // jQuery不要去处理发送的数据
            contentType: false, // jQuery不要去设置Content-Type请求头
            success: function (data) {
                layer.closeAll();
                if (data.result) {
                    Dialog.msg("操作成功!", function () {
                    });
                } else {
                    Dialog.msg("操作失败，请重新上传!", function () {
                    });
                }
                searcherBS.refresh();
                //清除表单内容
                $("#reportFile").val("");
                $("#remark").val("");
            }
        });
    }

    /**
     *下载报告
     */
    function showdownloadDialog() {
        var rowData = searcherBS.getRawData();
        if (rowData.length == 0) {
            Dialog.errorMsg("请选择一行进行下载！");
            return;
        }
        rowData=rowData[0];
        if(!rowData.deliverFirstFile&&!rowData.reportSecondFile&&!rowData.deliverThirdFile){
            Dialog.errorMsg("没有报告上传！");
            return;
        }
        //文件下载路径
        var node='';
        if(rowData.deliverFirstFile){
            node+="<div style='margin:20px;font-size:1.3em'><label><input type='checkbox' style='margin-top: 6px;' name='files' value='"+rowData.deliverFirstFile+"'>第一次出货检验报告</label></div>";
        }
        if(rowData.deliverSecondFile){
            node+="<div style='margin:20px;font-size:1.3em'><label><input type='checkbox' style='margin-top: 6px;' name='files' value='"+rowData.deliverSecondFile+"'>第二次出货检验报告</label></div>";
        }
        if(rowData.deliverThirdFile){
            node+="<div style='margin:20px;font-size:1.3em'><label><input type='checkbox' style='margin-top: 6px;' name='files' value='"+rowData.deliverThirdFile+"'>第三次出货检验报告</label></div>";
        }
        $("#downloadCheckbox").html(node);
        //下载报告窗口
        Dialog.open("下载文件", $("#downloadModal"),{area : ['400px','500px']});
    }

    function downloadReport(){
        $("#downloadForm").attr("action",ctxPath + "/orderItem/downloadFile");

        var checkReports=$("input[name='files']:checked");
        var len=checkReports.length;
        if(len==0){
            Dialog.errorMsg("请选择要下载的试用报告！");
            return;
        }
        $("#downloadForm").submit();
        layer.closeAll();
    }

    /**
     *查看报告
     */
    function showReportDetailDialog() {
        var rowData = searcherBS.getRawData();
        if (rowData.length == 0) {
            Dialog.errorMsg("请选择一行进行查看！");
            return;
        }
        rowData = rowData[0];
        var tableData = new Array();
        var deliverFirstFile = {type: '第一次出货检验报告', isUpload: "否", time: '', remark: ''};
        var deliverSecondFile = {type: '第二次出货检验报告', isUpload: "否", time: '', remark: ''};
        var deliverThirdFile = {type: '第三次出货检验报告', isUpload: "否", time: '', remark: ''};
        //第一次出货检验报告
        if (rowData.deliverFirstFile) {
            deliverFirstFile.isUpload = "是";
            deliverFirstFile.time = rowData.deliverFirstFile.substring(rowData.deliverFirstFile.lastIndexOf("_") + 1, rowData.deliverFirstFile.lastIndexOf(".")).replace(/~/g,':');
        }
        if (rowData.deliverFirstRemark) {
            deliverFirstFile.remark = rowData.deliverFirstRemark;
        }
        //第二次出货检验报告
        if (rowData.deliverSecondFile) {
            deliverSecondFile.isUpload = "是";
            deliverSecondFile.time = rowData.deliverSecondFile.substring(rowData.deliverSecondFile.lastIndexOf("_") + 1, rowData.deliverSecondFile.lastIndexOf(".")).replace(/~/g,':');
        }
        if (rowData.deliverSecondRemark) {
            deliverSecondFile.remark = rowData.deliverSecondRemark;
        }
        //第三次出货检验报告
        if (rowData.deliverThirdFile) {
            deliverThirdFile.isUpload = "是";
            deliverThirdFile.time = rowData.deliverThirdFile.substring(rowData.deliverThirdFile.lastIndexOf("_") + 1, rowData.deliverThirdFile.lastIndexOf(".")).replace(/~/g,':');
        }
        if (rowData.deliverThirdRemark) {
            deliverThirdFile.remark = rowData.deliverThirdRemark;
        }
        tableData[0] = deliverFirstFile;
        tableData[1] = deliverSecondFile;
        tableData[2] = deliverThirdFile;
        //查看报告窗口
        Dialog.open("查看报告", $("#reportDetailModal"), {area: ['800px', '480px']});
        $("#reportDetailTable").bootstrapTable('destroy');
        $('#reportDetailTable').bootstrapTable({data: tableData});
    }

</script>
<script type="text/javascript">
    // Firefox, Google Chrome, Opera, Safari, Internet Explorer from version 9
    // function OnInput (event) {
    // alert ("The new content: " + event.target.value);
    // }

    function change(obj) {
        var dueOut = obj.poCount-obj.shippedQty;
        var text = event.target.value;
        alert("原值："+dueOut);
        alert("新值："+text);
    }
    // Internet Explorer
    // function OnPropChanged (event) {
    //if (event.propertyName.toLowerCase () == "value") {
    //  alert ("The new content: " + event.srcElement.value);
    //  }
    // }
</script>
</body>
</html>